perm filename SAIOPN.FAI[S,AIL]1 blob
sn#100441 filedate 1974-05-05 generic text, type T, neo UTF8
COMPIL(OPN,<OPEN,RELEASE,SETPL,CHNCDB>
,<GETCHN,SAVE,RESTR,CORGET,FLSCAN,SIMIO,X33,X22,X11,CORREL>
,<OPEN RELEASE AND SETPL FUNCTIONS>)
.OPN:
HERE (OPEN)
PUSH P,-7(P)
PUSH P,[0]
PUSHJ P,RELEASE ;SIMPLE
PUSHJ P,SAVE ;SAVE ACS
MOVEI C,IOTLEN ;SIZE
PUSHJ P,CORGET ;OBTAIN A BLOCK
JRST BADOPN ;CAN'T GET IT
MOVE CDB,B ;CDB ptr to CHANNEL TABLE
MOVEI LPSA,0 ;NOW GET READY IN CASE OF ERROR
SUB SP,X22
POP P,TEMP ;RETURN ADDRESS
POP P,ENDFL(CDB) ;END OF FILE FLAG ADDRESS
POP P,BRCHAR(CDB) ;BREAK CHAR ADDRESS
POP P,ICOUNT(CDB) ;INPUT COUNT ADDRESS
POP P,OBUF(CDB) ;NUMBER OF OUTPUT BUFFERS
POP P,IBUF(CDB) ;NUMBER OF INPUT BUFFERS
POP P,Z ;DATA MODE
POP P,CHNL ;DATA CHANNEL
SETZM LINNUM(CDB)
SETZM SOSNUM(CDB)
SETZM PAGNUM(CDB)
CHKCHN CHNL,<OPEN> ;ASSURE VALID
HRRZI X,750000 ;ERROR BITS POSSIBLY ENABLED -- WAS A HRROI
ANDCM X,Z ;ERROR BITS ACTUALLY ENABLED ARE 0
MOVEM X,ERRTST(CDB) ;SAVE ENABLATIONS
TRZ Z,750000 ;REMOVE IRRELEVANT BITS
ILLMOD ←← 777777
CMU <
ILLMOD ←← 377776 ;BIT 400000 FOR SPECIAL DEVICE (CMU)
TLZE Z,10000 ;IOACTIVE BIT TO BE SET ON OPEN ??? (LDE)
TRO Z,10000 ;YES
>;CMU
TLNE Z,ILLMOD ;CHECK VALIDITY SOMEWHAT
ERR <OPEN: INVALID DATA MODE>,1
MOVEM Z,DMODE(CDB) ;STORE MODE
MOVEI X,DNAME(CDB) ;WHERE SIXBIT'S TO GO
PUSHJ P,FLSCAN ;GET DEVICE NAME
JUMPN Y,[
SKIPN @ENDFL(CDB) ;FLAGGED??
ERR <INVALID DEVICE NAME FOR OPEN>,1
JRST .+1
]
HLRZ TEMP,DNAME(CDB) ;GET LH DEVICE NAME
MOVSI Z,400000 ;BIT TO MARK WITH
CAIN TEMP,'PTY' ; ,
JRST MRKTYB ;MARK AS A TTY
MOVE TEMP,DNAME(CDB) ;PICK UP DEVICE AGAIN (FULL SIXBIT)
CALL6 (TEMP,DEVCHR) ;GET CHARACTERISTICS
TLNE TEMP,10 ;A TTY???
MRKTYB: IORM Z,TTYDEV(CDB); IT'S A TTY
HRRZI Z,-1 ;TO TEST RIGHT HALF
SETZM BFHED(CDB) ;CLEAR HEADER POINTER
LDB E,[POINT 4,DMODE(CDB),35] ;DATA MODE
CAIL E,15 ;DUMP MODE?
JRST AGNN ; YES, NO BUFFER HEADER WORD
MOVEI TEMP,OBPNT(CDB) ;IF OUTPUT, SET POINTER
TDNE Z,OBUF(CDB) ;ANY OUTPUT BUFFERS?
HRLM TEMP,BFHED(CDB)
MOVEI TEMP,IBPNT(CDB) ;SAME FOR INPUT
TDNE Z,IBUF(CDB) ;ANY INPUT BUFFERS?
HRRM TEMP,BFHED(CDB)
AGNN: XCT IOOPEN,SIMIO ; OPEN CHAN,MODE
JRST [SKIPE @ENDFL(CDB) ;DOES USER WANT TO KNOW?
JRST NORELO ;YES, RELEASE CDB, ERASE ALL OF ATTEMPT
JRST RTRY]
MOVEI Z,0 ;FOR DUMMY (AND REAL) OUTBUF
PUSHJ P,GETBFS ;GET CORE, DO THE OUTBUFS (OR SIMULATIONS)
ADDI CDB,OBUF-OBPNT+1 ;RELOCATE FOR INPUT IN CDB
MOVEI Z,-1
PUSHJ P,GETBFS ;GET CORE, DO INBUFS
SUBI CDB,OBUF-OBPNT+1;RE-RELOCATE
CMU < ;FUNNY INPUT DEVICE
SKIPL DMODE(CDB) ;DID HE SPECIFY TO GET ERRS FROM
JRST STNIT ; NO.
HRLZI TEMP,400000
SKIPE IBUF(CDB) ;INPUT BUFFERS?
JRST [IORM TEMP,IBUF(CDB) ; YES
JRST STNIT]
SKIPE OBUF(CDB) ;OR OUTPUT BUFFERS?
JUMPA CHNL,[IORM TEMP,OBUF(CDB) ; YES
JRST STNIT]
ERR<OPEN: SPEECH DEV BUT NO BUFFERS, CHAN >,7
>;CMU
STNIT: ;SETOM JOBFF ;ONE MUST KNOW WHAT HE IS DOING TO USE
MOVEM CDB,@CDBLOC(USER) ;STORE CDB ADDR IN CHANS TABLE
SETZM @ENDFL(CDB) ;MARK OPEN SUCCESSFUL
JRST RESTR ;RESTORE ACS, RETURN
BADOPN: HRRZ TEMP,JOBREN ;NEXT START WILL ASK ALLOC
HRRM TEMP,JOBSA ;QUESTION
ERR <TOO MANY CHANNELS OR I/O BUFFERS REQUESTED>,1,<(TEMP)>
RTRY: TERPRI <OPEN: DEVICE NOT AVAILABLE>
TERPRI <TYPE "R" TO RETRY, "X" TO GO ON WITHOUT>
PRINT <?>
PUUO TEMP
CAIN TEMP,"R" ;TRY AGAIN?
JRST AGNN ;YES
SETOM @ENDFL(CDB) ;MARK A LOSER
JRST NORELO
GETBFS: SETZM ONAME(CDB) ;CLEAR FILE NAME
HRRZ Y,OBUF(CDB) ;NUMBER OF BUFFERS
HLRZ D,OBUF(CDB) ;SIZE
EXPO <
HRRZS OBUF(CDB) ;MARK FOR SPECIAL TEST
>;EXPO
JUMPE Y,GBUFRT ;NO BUFFERS
JUMPE D,GETDES ;WANTS DEFAULT SIZE
ANDI D,7777 ;MAX BUFFER SIZE
HRLZ A,D ;SIZE IN LH
PUSHJ P,GETCOR ;GET THE CORE (SURPRISE!)
SETZM OCOWNT(CDB) ;IN CASE NO ACTUAL INBUF (OUTBUF) DONE
CAIL E,15 ;DUMP MODE?
JRST GBUFRT ; YES, DON'T ACTUALLY FUDGE UP BUFFERS
NOEXPO <;USE UINBF, UOUTBF
MOVEM B,JOBFF ;B FROM CORGET HAS BUFFER AREA ADDRESS
SUBI D,2 ;GETCOR INCREMENTED
HRRZ C,Y
MOVE A,[UINBF C]
JUMPN Z,.+2
MOVE A,[UOUTBF C]
DPB CHNL,[POINT 4,A,12]
XCT A ;DO THE ALLOCATIONS
POPJ P,
>;NOEXPO
EXPO <
ADDI B,1 ;SECOND WORD
BUFC1: HRR A,B
SOJLE Y,BUFC2
ADD B,D ;NEXT ONE
MOVEM A,(B) ;MAKE POINT TO PREV
JRST BUFC1
BUFC2: MOVE B,OBUF(CDB) ;BACK TO FIRST
MOVEM A,1(B) ;LINK IT TOO
HRLI A,400000 ;RING-USE BIQ
MOVEM A,OBPNT(CDB) ;BUFFER PTR
POPJ P,
>;EXPO
GETCOR: ADDI D,2 ;+2 FOR ACCOUNTING
MOVE C,D
IMUL C,Y ;TOTAL CORE NEEDED
PUSHJ P,CORGET ;GRAB IT
ERR <OPEN: NOT ENUFF CORE FOR BUFFERS>
HRRZM B,OBUF(CDB) ;SAVE SO CAN RELEASE
POPJ P,
GETDES: MOVEI A,1 ;1 DUMMY BUFFER
CAIL E,15 ;GOOD OLD DUMP MODE?
JRST [MOVEI D,202 ;ASSUME THIS, SINCE INBUF/OUTBUF WON'T
JRST GDIT] ; WORK IN DUMP MODE
MOVEI TEMP,BRKDUM-1(USER)
MOVEM TEMP,JOBFF
PUSHJ P,GETIOB ;DUMMY IN/OUBUF
LDB D,[POINT 17,BRKDUM(USER),17] ;GET THE SIZE
GDIT: PUSHJ P,GETCOR ;GET THE CORE
SETZM OCOWNT(CDB) ;CLEAR BYTE COUNT
CAIL E,15 ;DUMP MODE?
JRST GBUFRT ;YES, NO BUFFER STRUCTURE
MOVEM B,JOBFF
MOVE A,Y ;NUMBER OF BUFFERS
PUSHJ P,GETIOB ;NOW FOR REAL
GBUFRT: SETOM JOBFF ;FOR SPITE
POPJ P,
GETIOB: SKIPN Z
XCT IOOUTBUF,SIMIO ;DO OUTBUF
SKIPE Z
XCT IOINBUF,SIMIO ;INBUF
POPJ P,
SUBTTL RELEASE
HERE(RELEASE)
.RELS:
SETOM JOBFF ;MARK INVALID
PUSHJ P,SAVE ;SAVE REGS, GET USER, SAVE RETURN
MOVE LPSA,X33
MOVE CHNL,-2(P) ;CHANNEL #
CHKCHN CHNL,<RELEASE> ;VALIDATE
SKIPN CDB,@CDBLOC(USER) ;GET ADDR FROM CHANS TABLE-- CHANNEL OPEN?
JRST RESTR ;CHANNEL NOT OPEN, FORGET IT
SETZM @CDBLOC(USER) ;CLEAR CHANS TABLE ENTRY
HRRZ D,-1(P) ;THE DEFAULT OR USER SPECIFIED INHIBIT BITS
XCT IORELEASE,SIMIO ;RELEASE CHAN,0
HRRZ B,IBUF(CDB) ;RELEASE ANY INPUT
PUSHJ P,BUFREL ; BUFFERS
HRRZ B,OBUF(CDB) ;ALSO OUTPUT
PUSHJ P,BUFREL ; BUFFERS
NORELO: HRRZ B,CDB ;WHERE TO RELEASE
PUSHJ P,CORREL ;GIVE CDB BACK
JRST RESTR ;RESTORE AND RETURN
BUFREL: JUMPN B,CORREL ;RELEASE IF ANY TO RELEASE
POPJ P, ;ELSE RETURN
HERE(SETPL)
PUSHJ P,SAVE
MOVE CHNL,-4(P) ;GET CHANNEL
PUSHJ P,GETCHN ;VALIDATE, LOAD CDB
POP P,TEMP ;RETURN ADDRESS (GET OUT OF WAY)
POP P,SOSNUM(CDB)
SETZM @SOSNUM(CDB)
POP P,PAGNUM(CDB)
SETZM @PAGNUM(CDB)
POP P,LINNUM(CDB) ;LINE NUMBER
SETZM @LINNUM(CDB)
MOVE LPSA,X11 ;REMOVE CHANNEL NUMBER FROM STACK
JRST RESTR
HERE(CHNCDB)
PUSHJ P,SAVE ;
MOVE CHNL,-1(P) ;GET CHANNEL NUMBER
PUSHJ P,GETCHN ;CHECK & LOAD CDB
MOVEI 1,DMODE(CDB) ;GET VALUE
MOVEM 1,RACS+1(USER) ;SO RESTR WINS
MOVE LPSA,X22 ;
JRST RESTR ;RETURN
HERE(OPNSP1) ;PERHAPS PUT GETSTS HERE
ERR <DRYROT IN OPEN SPARES>
ENDCOM (OPN)